package 十大排序算法;

public class 二分查找 {
    public static int biSearch(int[]array,int a){
        int lo = 0;
        int hi = array.length-1;
        int mid ;
        while (lo<=hi){
            mid = (lo+hi)/2;
            if (array[mid] == a){
                return mid+1;
            }
            if (array[mid]<a){
                lo = mid+1;
            }
            if (array[mid]>a){
                hi = mid-1;
            }
        }
        return -1;
    }
}
